#include "IrDecoderManager.h"

IrDecoderManager::IrDecoderManager( ILoggerPtr logger ) : m_Logger(logger)
{

}

void IrDecoderManager::add ( IIrDecoderPtr decoder )
{
	m_Decoders.push_back(decoder);
}

void IrDecoderManager::add ( IIrDecoder * decoder )
{
	IIrDecoderPtr p(decoder);
	m_Decoders.push_back(p);
}

void IrDecoderManager::resetAll()
{
	DecoderList::iterator begin = m_Decoders.begin();
	while ( begin != m_Decoders.end() )
	{
		(*begin)->reset();
		begin++;
	}
}

void IrDecoderManager::process ( unsigned long * data, size_t count )
{
	DecoderList::iterator begin = m_Decoders.begin();
	while ( begin != m_Decoders.end() )
	{
		if ( (*begin)->process(data,count) )
		{
			resetAll();
			return;
		}
		begin++;
	}
}

